{% extends "base.html" %}

{% block content %}
    <div class="row justify-content-center">
        <div class="col-md-6">
            <div class="card">
                <div class="card-header">
                    <h2 class="text-center">用户登录</h2>
                </div>
                <div class="card-body">
                    <form method="POST" action="{{ url_for('auth.login') }}">
                        {{ form.hidden_tag() }}
                        <div class="form-group">
                            {{ form.username.label(class="form-control-label") }}
                            {% if form.username.errors %}
                                {{ form.username(class="form-control form-control-lg is-invalid") }}
                                <div class="invalid-feedback">
                                    {% for error in form.username.errors %}
                                        <span>{{ error }}</span>
                                    {% endfor %}
                                </div>
                            {% else %}
                                {{ form.username(class="form-control form-control-lg") }}
                            {% endif %}
                        </div>
                        <div class="form-group">
                            {{ form.password.label(class="form-control-label") }}
                            {% if form.password.errors %}
                                {{ form.password(class="form-control form-control-lg is-invalid") }}
                                <div class="invalid-feedback">
                                    {% for error in form.password.errors %}
                                        <span>{{ error }}</span>
                                    {% endfor %}
                                </div>
                            {% else %}
                                {{ form.password(class="form-control form-control-lg") }}
                            {% endif %}
                        </div>
                        <div class="form-check">
                            {{ form.remember(class="form-check-input") }}
                            {{ form.remember.label(class="form-check-label") }}
                        </div>
                        <div class="form-group mt-4">
                            {{ form.submit(class="btn btn-primary btn-block") }}
                        </div>
                    </form>
                </div>
                <div class="card-footer text-center">
                    <small>还没有账户？<a href="{{ url_for('auth.register') }}">立即注册</a></small>
                </div>
            </div>
        </div>
    </div>
{% endblock %}